home *** CD-ROM | disk | FTP | other *** search
/ Plug-In Power Pack for Netscape Communicator / Plug-In Power Pack for Netscape Communicator.iso / plugins / dataviews / dvdraw / demos / dsp_mgr / dsp_timer.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-08  |  2.0 KB  |  112 lines

  1. /************************  Time Out Routines ***********************/
  2. /* Include "Timer" Files */
  3. #ifdef WINNT
  4. #include <windows.h>
  5. #else
  6. #ifdef VMS
  7. #include <time.h>
  8. #else
  9.  
  10. #ifdef APOLLO
  11. #include <time.h>
  12. #include "base.h"
  13. #include "cal.h"
  14. #else
  15. #include <sys/time.h>
  16. #endif /* APOLLO */
  17.  
  18. #endif /* VMS */
  19.  
  20. #endif /* WINNT */
  21.  
  22. LOCAL LONG cur_time_in_sec;
  23. #define NUM_SECS_TO_STOP 10
  24.  
  25. /*-----------------------------------------------------------------*/
  26. LOCAL VOID
  27. InitTimer()
  28. {
  29. #ifdef WINNT
  30.  
  31.   DWORD time;
  32.   time = GetTickCount();  /* returns num milliseconds since windows started */
  33.   cur_time_in_sec = (LONG)(time / 1000);
  34.  
  35. #else
  36.  
  37. #ifdef VMS
  38.   INT time[2];
  39.  
  40.   SYS$GETTIM( time );
  41.   cur_time_in_sec = time[0] / 10000000; /* 10,000,000 gives the seconds */
  42.  
  43. #else
  44.  
  45. #ifdef APOLLO
  46.   time_$timeval_t tp;
  47.  
  48.   (VOID)gettimeofday( &tp, (struct timezone *)NULL );
  49.   cur_time_in_sec = tp.sec;
  50.  
  51. #else
  52.  
  53.   struct timeval tp;
  54.  
  55.   (VOID)gettimeofday( &tp, (struct timezone *)NULL );
  56.   cur_time_in_sec = tp.tv_sec;
  57. #endif /* APOLLO */
  58.  
  59. #endif  /* VMS */
  60.  
  61. #endif /* WINNT */
  62. }
  63.  
  64. /*-----------------------------------------------------------------*/
  65. LOCAL BOOLPARAM
  66. TimedOut()
  67. {
  68.   DV_BOOL timeout = NO;
  69. #ifdef WINNT
  70.  
  71.   INT time;
  72.   time = GetTickCount() / 1000;  /* returns num milliseconds since windows started */
  73.  
  74.   if ((time - cur_time_in_sec) >= NUM_SECS_TO_STOP )
  75.       timeout = YES;
  76. #else
  77.  
  78. #ifdef VMS 
  79.   INT time[2];
  80.  
  81.   SYS$GETTIM( time );
  82.   if( ( ( time[0]/10000000 ) - cur_time_in_sec ) >= NUM_SECS_TO_STOP )
  83.       timeout = YES;
  84.  
  85. #else
  86.  
  87. #ifdef APOLLO
  88.   time_$timeval_t tp;
  89.  
  90.   (VOID)gettimeofday( &tp, (struct timezone *)NULL );
  91.  
  92.   if ((tp.sec - cur_time_in_sec) >= NUM_SECS_TO_STOP )
  93.       timeout = YES;
  94. #else
  95.  
  96.   struct timeval tp;
  97.  
  98.   (VOID)gettimeofday( &tp, (struct timezone *)NULL );
  99.  
  100.   if ((tp.tv_sec - cur_time_in_sec) >= NUM_SECS_TO_STOP )
  101.       timeout = YES;
  102.  
  103. #endif /* APOLLO */
  104.  
  105. #endif /* VMS */
  106.  
  107. #endif /* WINNT */
  108.  
  109.   return timeout;
  110. }
  111.  
  112.